<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>mindsensors-magicwand-test1.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#pragma config(Sensor, S1,     MAGICWAND,      sensorI2CCustomFastSkipStates)</span>
<span class="preprocessor"></span><span class="comment">//*!!Code automatically generated by &#39;ROBOTC&#39; configuration wizard               !!*//</span>

<span class="comment">/*</span>
<span class="comment"> * $Id: mindsensors-magicwand-test1.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * mindsensors-magicwand.h provides additional functionality on top of the PCF8574 driver for</span>
<span class="comment"> * the Mindsensors Magic Wand. This program demonstrates how to use that API to</span>
<span class="comment"> * control the LEDs for fun and profit!</span>
<span class="comment"> *</span>
<span class="comment"> * Changelog:</span>
<span class="comment"> * - 0.1: Initial release</span>
<span class="comment"> *</span>
<span class="comment"> * Credits:</span>
<span class="comment"> * - Magic Wand driver originally written by Mike Partain a.k.a. Spiked3 (http://www.spiked3.com/)</span>
<span class="comment"> * - Big thanks to Mindsensors for providing me with the hardware necessary to write and test this.</span>
<span class="comment"> *</span>
<span class="comment"> * License: You may use this code as you wish, provided you give credit where it&#39;s due.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<span class="comment"></span>
<span class="comment"> * Xander Soldaat (xander_at_botbench.com)</span>
<span class="comment"> * 29 July 2012</span>
<span class="comment"> * version 0.1</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &quot;<a class="code" href="mindsensors-magicwand_8h.html" title="Mindsensors Magic Wand.">drivers/mindsensors-magicwand.h</a>&quot;</span>

task main () {

  <a name="a0"></a><a class="code" href="group___magic___wand.html#ga02739124b959de66fba08bc27dbfe852">MSMWclearALL</a>(MAGICWAND);

  <span class="keywordflow">while</span> (<span class="keyword">true</span>)
  {

    <span class="comment">// Blink LED 0 5 times</span>
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 5; i++)
    {
      <a name="a1"></a><a class="code" href="group___magic___wand.html#ga9e6d253b6b3b577171d640a794eb4b2a">MSMWsetLED</a>(MAGICWAND, 0, <span class="keyword">true</span>);
      wait1Msec(150);
      <a class="code" href="group___magic___wand.html#ga9e6d253b6b3b577171d640a794eb4b2a">MSMWsetLED</a>(MAGICWAND, 0, <span class="keyword">false</span>);
      wait1Msec(50);
    }

    <span class="comment">// Do the same as above, only use the toggle function</span>
    <span class="comment">// Toggle LED 4</span>
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 10; i++)
    {
      <a name="a2"></a><a class="code" href="group___magic___wand.html#ga74c6a457baee52433276c6d8174bf80c">MSMWtoggleLED</a>(MAGICWAND, 4);
      wait1Msec(200);
    }

    <span class="comment">// Flash pulse all of the LEDs quickly</span>
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 3; i++)
    {
      <a name="a3"></a><a class="code" href="group___magic___wand.html#gae1d7742ef96f374705821ef64f6ea8a7">MSMWsetALL</a>(MAGICWAND);
      wait1Msec(50);
      <a class="code" href="group___magic___wand.html#ga02739124b959de66fba08bc27dbfe852">MSMWclearALL</a>(MAGICWAND);
      wait1Msec(150);
    }

    <span class="comment">// Use a cool flash effect and clear them all</span>
    <a name="a4"></a><a class="code" href="group___magic___wand.html#ga532f13c1d6d3e90e449f609d21f7ffba">MSMWflashAndClear</a>(MAGICWAND, 4);

                <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 1; j &lt; 10; j++)
                {
                        <span class="keywordtype">int</span> r = random(7);
                        <a class="code" href="group___magic___wand.html#ga9e6d253b6b3b577171d640a794eb4b2a">MSMWsetLED</a>(MAGICWAND, r, <span class="keyword">true</span>);
                        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 10; i++)
                        {
                                <a class="code" href="group___magic___wand.html#ga74c6a457baee52433276c6d8174bf80c">MSMWtoggleLED</a>(MAGICWAND, 4);
                                wait1Msec(100);
                        }
                  <a class="code" href="group___magic___wand.html#ga9e6d253b6b3b577171d640a794eb4b2a">MSMWsetLED</a>(MAGICWAND, r, <span class="keyword">false</span>);
                }
    wait1Msec(500);
    <a class="code" href="group___magic___wand.html#ga02739124b959de66fba08bc27dbfe852">MSMWclearALL</a>(MAGICWAND);

  }


}

 <span class="comment">/*</span>
<span class="comment"> * $Id: mindsensors-magicwand-test1.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:42 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
